package com.effectiv.gooruda.rest.api.controller;

import org.springframework.social.facebook.api.Comment;
import org.springframework.social.facebook.api.Facebook;
import org.springframework.social.facebook.api.PagedList;
import org.springframework.social.facebook.api.PagingParameters;
import org.springframework.social.facebook.api.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/facebook/comment")
public class FacebookCommentOperations  {

	@RequestMapping(value = "/addcomment/{objectId}/{message}", method = RequestMethod.POST)
	public String addComment(@PathVariable("objectId") String objectId, @PathVariable("message") String message, Facebook facebook) {
		return facebook.commentOperations().addComment(objectId, message);
	}

	@RequestMapping(value = "/deletecomment/{commentId}", method = RequestMethod.DELETE)
	public void deleteComment(@PathVariable("commentId") String commentId, Facebook facebook) {
		facebook.commentOperations().deleteComment(commentId);
	}

	@RequestMapping(value = "/getcomment/{commentId}", method = RequestMethod.GET)
	public Comment getComment(@PathVariable("commentId") String commentId, Facebook facebook) {
		return facebook.commentOperations().getComment(commentId);
	}

	

	@RequestMapping(value = "/getcomments/{objectId}", method = RequestMethod.GET)
	public PagedList<Comment> getComments(@PathVariable("objectId") String objectId, PagingParameters pagedListParameters, Facebook facebook) {
		return facebook.commentOperations().getComments(objectId);
	}


	@RequestMapping(value = "/getlikes/{objectId}", method = RequestMethod.GET)
	public PagedList<Reference> getLikes(@PathVariable("objectId") String objectId, Facebook facebook) {
		return facebook.commentOperations().getLikes(objectId);
	}

}
